using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Elo.Exemplo.EFCodeFirst.Domain.Entities;

namespace Elo.Exemplo.EFCodeFirst.Domain.Mapping
{
	public class Alphabetical_list_of_productMap : EntityTypeConfiguration<Alphabetical_list_of_product>
	{
		public Alphabetical_list_of_productMap()
		{
			// Primary Key
			this.HasKey(t => new { t.ProductID, t.ProductName, t.Discontinued, t.CategoryName });

			// Properties
			this.Property(t => t.ProductID)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
				
			this.Property(t => t.ProductName)
				.IsRequired()
				.HasMaxLength(40);
				
			this.Property(t => t.QuantityPerUnit)
				.HasMaxLength(20);
				
			this.Property(t => t.CategoryName)
				.IsRequired()
				.HasMaxLength(15);
				
			// Table & Column Mappings
			this.ToTable("Alphabetical list of products");
			this.Property(t => t.ProductID).HasColumnName("ProductID");
			this.Property(t => t.ProductName).HasColumnName("ProductName");
			this.Property(t => t.SupplierID).HasColumnName("SupplierID");
			this.Property(t => t.CategoryID).HasColumnName("CategoryID");
			this.Property(t => t.QuantityPerUnit).HasColumnName("QuantityPerUnit");
			this.Property(t => t.UnitPrice).HasColumnName("UnitPrice");
			this.Property(t => t.UnitsInStock).HasColumnName("UnitsInStock");
			this.Property(t => t.UnitsOnOrder).HasColumnName("UnitsOnOrder");
			this.Property(t => t.ReorderLevel).HasColumnName("ReorderLevel");
			this.Property(t => t.Discontinued).HasColumnName("Discontinued");
			this.Property(t => t.CategoryName).HasColumnName("CategoryName");
		}
	}
}

